#include <iostream>
#include <algorithm>
using namespace std;
const int N = 2e5+10;
struct node{
    int l,r;
}a[N];
struct Compare{
    bool operator()(const node& left,const node& right){
        if(left.r==right.r){
            return left.l>right.l;
        }
        return left.r<right.r;
    }
};
int main() {
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i].l >> a[i].r;
    }
    sort(a,a+n,Compare());
    int sum=1;
    int j=0;
    for(int i=1;i<n;i++)
    {
        if(a[i].l>=a[j].r){
            sum++;
            j=i;
        }
    }
    cout << sum << endl;
    return 0;
}